﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAO_DTO_WS.DAO;
using DAO_DTO_WS.DTO;

namespace LayoutTemplate
{
    public partial class WebForm14 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((Session["ID"].ToString() == "") || (int.Parse(Session["TinhTrang"].ToString()) != 3))
                Response.Redirect("TrangLoi.aspx?Error=9");
        }

        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            ThanhVienDTO thanhvien = ThanhVienDAO.LayThanhVienTheoMa(int.Parse(Request.QueryString["id"]));
            if (string.Compare(tbHoTen.Text, string.Empty, true) != 0)
                thanhvien.HoTen = tbHoTen.Text;
            if (string.Compare(TbTenDN.Text, string.Empty, true) != 0)
                thanhvien.TenThanhVien = TbTenDN.Text;
            if (string.Compare(TbMatKhau.Text, string.Empty, true) != 0)
                thanhvien.MatKhau = TbMatKhau.Text;
            if (string.Compare(tbNgaySinh.Text, string.Empty, true) != 0)
                thanhvien.NgaySinh = Convert.ToDateTime(tbNgaySinh.Text);

            if (string.Compare(tbDienThoai.Text, string.Empty, true) != 0)
                thanhvien.DienThoai = tbDienThoai.Text;

            if (string.Compare(tbNoiO.Text, string.Empty, true) != 0)
                thanhvien.NoiO = tbNoiO.Text;



            ThanhVienDAO.SuaTV(thanhvien);
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            ThanhVienDTO thanhvien = ThanhVienDAO.LayThanhVienTheoMa(int.Parse(Request.QueryString["id"]));
            thanhvien.TinhTrang = 1;
            ThanhVienDAO.SuaTV(thanhvien);
            Response.Redirect("AdminDanhSach.aspx?id=1&tt=0&page=1");
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            ThanhVienDTO thanhvien = ThanhVienDAO.LayThanhVienTheoMa(int.Parse(Request.QueryString["id"]));
            thanhvien.TinhTrang = 0;
            ThanhVienDAO.SuaTV(thanhvien);
            Response.Redirect("AdminDanhSach.aspx?id=1&tt=0&page=1");
        }
    }
}
